package org.example.collection.list;

import java.util.*;

public class Demo2 {
    public static void main(String[] args) {
//        test1();
        test2();
    }

    private static void test2() {
        
    }

    private static void test1() {
        LinkedList<Integer> list = new LinkedList<>(List.of(1, 2, 3));
        // 普通for
        for (int i = 0; i < list.size(); i++) { // 123
            System.out.print(list.get(i));
        }
        System.out.println();
        // ListIterator
        ListIterator<Integer> integerListIterator = list.listIterator();
        while (integerListIterator.hasNext()) { // 123
            System.out.print(integerListIterator.next());
        }
        System.out.println();
        // DescendingIterator
        Iterator<Integer> integerDescendingIterator = list.descendingIterator();
        while (integerDescendingIterator.hasNext()) {   // 321
            System.out.print(integerDescendingIterator.next());
        }
        System.out.println();
        // 增强for
        for (Integer i : list) {    // 123
            System.out.print(i);
        }
        System.out.println();
        // lambda
        list.forEach(System.out::print);    // 123
    }
}
